<?php

namespace App\Providers;

use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Routing\Router;
use TCG\Voyager\Facades\Voyager as VoyagerFacade;
use TCG\Voyager\VoyagerServiceProvider as BaseVoyagerServiceProvider;

class VoyagerServiceProvider extends BaseVoyagerServiceProvider
{

    public function register()
    {
        if (route_prefix_is_admin()) {
            parent::register();
        }
        $this->loadHelpers();
    }

    public function boot(Router $router, Dispatcher $event)
    {
        // 只有URI前缀是 admin 的时候再去加载 Voyager
        if (route_prefix_is_admin()) {
            parent::boot($router, $event);
        }
    }
}
